﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using WeiboFilter.DAL;
using WeiboFilter.Models;
using WeiboFilter.KeywordsRelated;


namespace WeiboFilter
{
    public partial class addWords : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string wo = Server.UrlDecode(Request.QueryString[0]);
            string op = Server.UrlDecode(Request.QueryString[1]);

            string format = @"<p style='color:{0}'>{1}</p>";
            string result;

            //保证分词正确！！！
            KeyWords instance = new KeyWords(wo);
            if (instance.words.Count == 0)
            {
                result = string.Format(format, "Red", "不是有效单词");
                Response.Write(result);
                return;
            }

            WordsDAL wDAL = new WordsDAL(Session["customer"].ToString());

            Word w_new = new Word();
            w_new.content = wo;
            if (op == "-1")
                w_new.point = -100;
            else w_new.point = 100;
            w_new.times = 1;

            wDAL.UpdateWordInfo(w_new);
            result = string.Format(format, "Green", "更新/加入单词成功");

            Response.Write(result);


        }
    }
}